<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="手机号：">
          <el-input v-model="listPram.mobile" placeholder="手机号" clearable style="width: 200px;"
                    class="selWidth"/>
        </el-form-item>
        <el-form-item label="时间范围">
          <el-date-picker
              v-model="value1"
              type="datetimerange"
              value-format="yyyy-MM-dd HH:mm:ss"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="handleDateChange">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click.native="getList">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="formLoading" :data="listData.records" style="width: 100%" size="small" highlight-current-row>
        <el-table-column prop="id" label="ID" min-width="50"/>
        <el-table-column prop="orderSn" label="订单号" min-width="150"/>
        <el-table-column prop="mobile" label="手机号" min-width="150"/>
        <el-table-column prop="createTime" label="下单时间" min-width="100"/>
        <el-table-column prop="amount" label="金额" min-width="80"/>
        <el-table-column prop="buyTime" label="支付时间" min-width="100"/>
        <!--        <el-table-column label="操作" min-width="80" fixed="right" align="center">-->
        <!--          <template slot-scope="scope">-->
        <!--            <el-button  size="mini" type="primary" @click="jumpNewPage(scope.row.phone)"  >详情</el-button>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[10,20,50,80,100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listData.total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>
<script>
import {
  rechargeAmount,
} from "@/api/home";
import {optionsList} from "@/api/business";

export default {
  components: {},
  props: {
    type: {
      default: null
    }
  },
  data() {
    return {
      value1: '',
      formLoading: false,
      listData: {records: [], total: 0},
      value: [],
      options: [{
        value: '',
        label: '',
        children: [{
          value: '',
          label: '',
          children: [{
            value: '',
            label: ''
          }]
        }]
      }],
      listPram: {
        page: 1,
        limit: 10,
        mobile: '',
        startTime: '',
        endTime: ''
      },
    }
  },
  mounted() {
    this.getList();
    this.getOptions();
  },
  methods: {
    getOptions() {
      optionsList().then(res => {
        this.options = res
      })
    },
    handleChange(value) {
      this.listPram.areaId = value[2]
    },
    jumpNewPage(mobile) {
      let routeLogin = this.$router.resolve({
        path: "/user/member",
        query: {
          keyword: `${mobile}`
        }
      });
      window.open(routeLogin.href, '_blank');
      //如果希望在新页面中打开超链接，则需要设置跳转方式为  _blank
    },
    handleDateChange(value) {
      this.listPram.startTime = value[0];
      this.listPram.endTime = value[1];
    },
    getList() {
      rechargeAmount(this.listPram).then(res => {
        this.listData = res
      }).finally(() => {
        this.formLoading = false;
      })
    },
    close() {
      this.$emit('hideEditDialog')
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
    resetQuery() {
      this.value1 = ''
      this.listPram.page = 1;
      this.listPram.mobile = '';
      this.listPram.limit = 10;
      this.listPram.endTime = '';
      this.listPram.startTime = '';

      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep {
  .el-upload {
  }
}

.img {
  width: 80px;
  height: 80px;
  border-radius: 100px;
}
</style>
